package GUI;

import redis.clients.jedis.Jedis;
import 实体.RedisPool;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class 更改密码 {
    private JFrame frame;
    private JPanel panel1;
    private JPasswordField passwordField1;
    private JButton 更改密码Button;
    private JTextField textField1;
    private JPasswordField passwordField2;

    public 更改密码() {
        更改密码Button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                Jedis jedis= RedisPool.getJedis();
                if (textField1.equals("")){
                    JOptionPane.showMessageDialog(null, "用户名不能为空！", "警告",JOptionPane.WARNING_MESSAGE);
                }
                else if(!jedis.exists(textField1.getText())){
                    JOptionPane.showMessageDialog(null, "用户名不存在！", "警告",JOptionPane.WARNING_MESSAGE);
                }
                else {
                    jedis.set(textField1.getText(),passwordField1.getText());
                    JOptionPane.showMessageDialog(null, "更改成功！");
                    frame.dispose();
                }
            }
        });
    }

    public static void main(String[] args) {
        界面();
    }
    public static void 界面(){
        更改密码 更改=new 更改密码();
        更改.frame=new JFrame("游泳管理系统");
        更改.frame.setContentPane(更改.panel1);
        更改.frame.setSize(500,400);
        更改.frame.setLocation(500, 200);
        更改.frame.setVisible(true);
        更改.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}
